<template>
	<view class="body">
		<view class="context">
			<view class="title-lan">
				<view class="jian" @click="back">
					<image src="https://splendid.oss-cn-beijing.aliyuncs.com/static/zhengyulan/back-arrow.png" mode="">
					</image>
				</view>
				<view class="content">
					以案说法
				</view>
			</view>
			<view class="inp">
				<input type="text" name="" id="" v-model="sing" placeholder="搜索感兴趣的内容">

				<image src="https://splendid.oss-cn-beijing.aliyuncs.com/static/zhengyulan/search.png" mode="" @click="search"></image>

			</view>
			<scroll-view scroll-y="true" class="scrolly-contair">
				<view class="swiper">
					<swiper class="swiper" circular :indicator-dots="indicatorDots" :autoplay="true" :interval="2000"
						:duration="duration">
						<swiper-item>
							<view class="swiper-item uni-bg-red">
								<image src="https://img1.baidu.com/it/u=2295474157,2699130201&fm=253&fmt=auto&app=138&f=JPEG?w=750&h=500" mode="" class="swiperimg"></image>
							</view>
						</swiper-item>
						<swiper-item>
							<view class="swiper-item uni-bg-green">
								<image src="https://img0.baidu.com/it/u=2019423475,2066895883&fm=253&fmt=auto&app=138&f=JPEG?w=600&h=400" mode="" class="swiperimg"></image>
							</view>
						</swiper-item>
						<swiper-item>
							<view class="swiper-item uni-bg-blue">
								<image src="https://img2.baidu.com/it/u=2281382382,569170405&fm=253&fmt=auto&app=138&f=JPEG?w=667&h=500" mode="" class="swiperimg"></image>
							</view>
						</swiper-item>
					</swiper>
				</view>
				<view class="dd">
					<view class="card">

						<view class="cards" @click="detaily" v-for="item in data">
							<view class="head">
								<view class="jpg">
									<image
										:src=item.picUrl
										mode=""></image>
								</view>
								<view class="text">
								{{item.title}}
								</view>
							</view>
							<view class="contex">
								2024年9月，按照机动车排放检验领域第三方机构专项...
							</view>
							<view class="riqi">
								<text>2024-03-05</text>
								<view class="yanjing">
									<view class="jingyan">
										<image
											src="https://splendid.oss-cn-beijing.aliyuncs.com/static/zhengyulan/eyes.png"
											mode=""></image>
									</view>
									<view class="rednumber">
										阅读量：3035
									</view>
								</view>
							</view>
						</view>


					</view>


				</view>
			</scroll-view>


		</view>
	</view>



</template>

<script setup>
	import {
		onShow,
	} from "@dcloudio/uni-app"
import { ref } from "vue";
	let back = () => {
		uni.navigateBack({
			delta: 1,
		})
	}
	// 搜索框事件
	let handleIconClick = () => {
		console.log("jj");
	}
	let detaily = () => {
		uni.navigateTo({
			url: "/homePageOther/CaseSpeakDetail/index"
		})
	}
	var data =ref([])
	var sing = ref("")
	function search (){
		getdata()
	}
	
	onShow(()=>{
		// 修改请求方式为 JSONP（聚合数据支持 JSONP）
		getdata()
	})
	function getdata (){
		uni.request({
		    url: "https://apis.tianapi.com/internet/index",
		    data: {
		    num:20,
		     key: "e8857a22c90b89a9ecae6db6b954dcf2",
			 word:sing.value,
			 // page:10,
		    },
		    success(res) {
		        // console.log("JSONP 返回数据:", res);
				console.log(res.data);
		        data.value = res.data.result.newslist;
		    }
		});
	}
</script>

<style lang="scss" scoped>
	.scrolly-contair{
		height: calc(100vh - 142rpx - 125rpx );
		overflow: auto;
	}
	.inp {
		width: 690rpx;
		height: 75rpx;
		background: #F7F7FE;
		border-radius: 38rpx;
		margin: 25rpx auto;
		color: #ABABBB;
		position: relative;

		input {
			width: 690rpx;
			height: 75rpx;
			color: #333333;
			background: #F7F7FE;
			border-radius: 38rpx;
			text-indent: 34rpx;
		}

		image {
			width: 30rpx;
			height: 31rpx;
			position: absolute;
			top: 23rpx;
			right: 45rpx;
		}
	}

	.swiper {
		width: 690rpx;
		height: 259rpx;
		margin: 0 auto;
		// background-color: #666;
	}

	.swiperimg {
		width: 690rpx;
		height: 259rpx;
	}

	.body {
		width: 100%;
		height: 100vh;

		.context {
			width: 750rpx;
			height: 853rpx;
			background-image: url("https://splendid.oss-cn-beijing.aliyuncs.com/static/zhengyulan/juxing.png");
			background-size: contain;
			/* 确保图片完整显示 */
			// background-position: center;   /* 图片居中 */
			background-repeat: no-repeat;
			/* 避免重复 */
			// overflow: hidden;
		}

		.title-lan {
			width: 750rpx;
			height: 142rpx;
			position: relative;
			overflow: hidden;

			.jian {
				width: 18rpx;
				height: 31rpx;
				position: absolute;
				top: 50rpx;
				left: 20rpx;

				image {
					width: 18rpx;
					height: 31rpx;
				}
			}

			.content {
				width: 140rpx;
				height: 33rpx;
				font-family: Source Han Sans CN;
				font-weight: 500;
				font-size: 35rpx;
				color: #FFFFFF;
				line-height: 33rpx;
				position: absolute;
				left: 250rpx;
				top: 50rpx;
			}
		}
	}


	// 搜索框样式
	.search-result {
		padding-top: 10rpx;
		padding-bottom: 20rpx;
		text-align: center;

	}

	.custom-search-bar {
		flex-direction: row-reverse;
		/* 反转内部元素顺序 */
	}

	.search-result-text {
		text-align: center;
		font-size: 14rpx;
		color: #666;
	}

	.example-body {
		/* #ifndef APP-NVUE */
		display: block;
		/* #endif */
		padding: 0rpx;
	}

	.uni-mt-10 {
		margin-top: 10rpx;
	}

	/* 父容器 .dd */
	.dd {
		width: 750rpx;
		display: flex;
		flex-direction: column;
		gap: 20rpx;
		padding: 30rpx;
	}

	/* 卡片容器 .card */
	.card {
		width: 691rpx;
		border-radius: 7rpx;
		background-color: #f3f5f7;
		position: relative;
	}

	/* 卡片内部结构 .cards */
	.cards {
		width: 691rpx;
		height: 242rpx;
		margin-bottom: 20rpx;
		background-color: #FFFFFF;
		border-radius: 7rpx;
		position: relative;
		overflow: hidden;
	}

	/* 标题区域 .head */
	.head {
		margin-left: 10rpx;
		margin-top: 30rpx;
		width: 600rpx;
		display: flex;
		background-color: #FFFFFF;
	}

	/* 图标容器 .jpg */
	.jpg {
		width: 31rpx;
		height: 31rpx;
	}

	.jpg image {
		width: 31rpx;
		height: 31rpx;
	}

	/* 标题文字 .text */
	.text {
		margin-left: 10rpx;
		width: 565rpx;
		height: 74rpx;
		font-family: Source Han Sans CN;
		font-weight: 700;
		font-size: 30rpx;
		color: #070707;
	}

	/* 内容摘要 .contex */
	.contex {
		width: 596rpx;
		height: 35rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		font-size: 24rpx;
		color: #666666;
		line-height: 45rpx;
		position: absolute;
		top: 120rpx;
		left: 30rpx;
		background-color: #FFFFFF;
		line-height: 35rpx;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	/* 日期和阅读量区域 .riqi */
	.riqi {
		width: 360rpx;
		height: 30rpx;
		bottom: 30rpx;
		position: absolute;
		right: 20rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.riqi text {
		display: inline-block;
		width: 160rpx;
		height: 30rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		font-size: 21rpx;
		color: #9494A3;
		line-height: 38rpx;
	}

	/* 眼睛图标容器 .yanjing */
	.yanjing {
		width: 190rpx;
		height: 30rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	/* 眼睛图标 .jingyan */
	.jingyan {
		width: 25rpx;
		height: 18rpx;
		line-height: 18rpx;
	}

	.jingyan image {
		width: 25rpx;
		height: 18rpx;
	}

	/* 阅读量文本 .rednumber */
	.rednumber {
		width: 160rpx;
		height: 19rpx;
		display: flex;
		font-family: Source Han Sans CN;
		font-weight: 400;
		font-size: 21rpx;
		color: #9494A3;
		line-height: 19rpx;
	}
</style>